package com.wjj.config;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import java.util.Arrays;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description
 * @Author junjun Wang
 * @Date Create in 16:22 2023/12/8
 **/
@Configuration
public class DefinedHystrixConfig {

	/**
	 * 开启Hystrix Dashboard监控
	 *
	 * @return
	 */
	@Bean
	public ServletRegistrationBean servletRegistrationBean() {
		ServletRegistrationBean registrationBean = new ServletRegistrationBean(
				new HystrixMetricsStreamServlet());
		registrationBean.setLoadOnStartup(1);
		registrationBean.setUrlMappings(Arrays.asList("/actuator/hystrix.stream"));
		registrationBean.setName("HystrixMetricsStreamServlet");
		return registrationBean;
	}
}
